package cn.samler.shopapi.Model.Sys;

import lombok.Data;

@Data
public class Response {
    private int ret;
    private String msg;
    private Object data;

    public static Response success() {
        return getInstance(0, "success", null);
    }

    public static Response success(String msg) {
        return getInstance(0, msg, null);
    }

    public static Response success(Object data) {
        return getInstance(0, "success", data);
    }

    public static Response success(String msg, Object data) {
        return getInstance(0, msg, data);
    }

    public static Response failure() {
        return getInstance(-1, "failure", null);
    }

    public static Response failure(String msg) {
        return getInstance(-1, msg, null);
    }

    public static Response failure(Object data) {
        return getInstance(-1, "failure", data);
    }

    public static Response failure(String msg, Object data) {
        return getInstance(-1, msg, data);
    }

    public static Response getInstance(int retCode, String msg, Object data) {
        Response resp = new Response();
        resp.setRet(retCode);
        resp.setMsg(msg);
        resp.setData(data);

        return resp;
    }
}
